package com.jgp.sys.ui;

import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;

/**
 * 项目   jgp-cloud-parent
 * 作者   loufei
 * 时间   2019/4/10
 */
public class ReuseableStream {
    
    private InputStream inputStream;
    
    public ReuseableStream(InputStream inputStream) {
        if (!inputStream.markSupported()) {
            this.inputStream = new BufferedInputStream(inputStream);
        } else {
            this.inputStream = inputStream;
        }
    }
    
    public InputStream open() {
        inputStream.mark(Integer.MAX_VALUE);
        return inputStream;
    }
    
    public void reset() throws IOException {
        inputStream.reset();
    }
}
